<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Auth extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('admin_auth',array('engine'=>'MyISAM'));
        $table->addColumn('auto_id', 'integer',array('limit' => 11,'identity'=>true,'signed'=>true,'comment'=>'主键'))
            ->addColumn('auth_name', 'string',array('limit' => 25,'comment'=>'权限名称'))
            ->addColumn('auth_controller', 'string',array('limit' => 25,'default'=>'','comment'=>'控制器'))
            ->addColumn('auth_action', 'string',array('limit' => 25,'default'=>'','comment'=>'方法'))
            ->addColumn('pid', 'integer',array('limit' => 5,'default'=>0,'comment'=>'父级权限'))
            ->addTimestamps()
            // ->addIndex(array('id'), array('primary' => true))
            ->create();
    }

    public function down(){
        $this->execute('DELETE FROM status');
    }
}
